<template>
	<view class="wrapper">
		<image src="../../static/bizhan/logo.png" mode="aspectFill" class="logo"></image>
		<view class="input_box center">
			<image src="../../static/start/account.png" mode="aspectFill"></image>
			<input type="text" style="color: #fff;" placeholder="请输入手机号" placeholder-class="c999 f30" class="flex" v-model="telephone" />
		</view>
		<view class="input_box center">
			<image src="../../static/start/pwd.png" mode="aspectFill"></image>
			<input :type="text" placeholder="输入密码" placeholder-class="c999 f30" class="flex" v-model="password" style="border: none;color: #fff; background-color: #0E1B45; outline: none;"/>
			<image src="../../static/start/open_eye.png" mode="aspectFill" @tap.stop="changeText('password')" v-show="text == 'text'"></image>
			<image src="../../static/start/close_eye.png" mode="aspectFill" @tap.stop="changeText('text')" v-show="text == 'password'"></image>
		</view>
		<view class="center space-between">
			<!-- <text class="f26 c666" @tap="$open('./forget')">忘记密码</text> -->
			<text class="f26 c666" @tap="$open('./register')">注册用户</text>
		</view>
		<view class="btn  cfff center" @tap="login">登录</view>
		<!-- <image src="../../static/start/smslogin.png" mode="aspectFill" class="sms" @tap="$open('./smsLogin')"></image> -->
	</view>
</template>

<script>
import md5 from '../../common/md5.min.js';
export default {
	data() {
		return {
			telephone: '',
			password: '',
			text: 'password'
		};
	},
	onShow() {
		if(uni.getStorageSync('userinfo')!=''){
			// this.$open('../index/index',1)
			this.$open('../bizhan/ore',1)
		}
	},
	onLoad() {},
	methods: {
		login() {
			let that = this;
			if (that.password == '') {
				this.$sToast('密码不能为空');
				return;
			}
			if (that.telephone == '') {
				this.$sToast('手机号不能为空');
				return;
			}
			if (!/^1[23456789]\d{9}$/.test(that.telephone)) {
				this.$sToast('手机号格式错误');
				return false;
			}
			// 获取经纬度
			// uni.getLocation({
			// 	type: 'gcj02',
			// 	geocode: true,
			// 	success(e) {
			// 		// 获取系统信息
			// 		uni.getSystemInfo({
			// 			success(system) {
			// 				console.log(system);
							that.$ajax(
								that.apiList.login,
								{
									// latitude: e.latitude,
									// longitude: e.longitude,
									// location: e.address,
									telephone: md5(that.telephone),
									password: md5(that.password),
									// model: system.model,
									// osVersion: system.version,
									// serial: system.system
								},
								'GET'
							).then(res => {
								uni.setStorageSync('telephone', that.telephone);
								uni.setStorageSync('userinfo', res.data);
								 let userId  =  res.data.userId
									let access_token = res.data.access_token
								that.$sToast('登陆成功')
								// that.$open('../index/index',2,1500)
								that.$open('../bizhan/ore?userId='+userId+'&access_token='+access_token,2,1500)
							});
			// 			}
			// 		});
			// 	},
			// 	fail(e) {
			// 		console.log(e);
			// 	}
			// });
		},
		changeText(text) {
			this.text = text;
		}
	}
};
</script>

<style lang="scss">
	page {
		background: #0E1B45;
	}
.wrapper {
	padding: 0 30rpx;
	.space-between {
		margin: 37rpx 0 47rpx;
	}
	.sms {
		position: fixed;
		bottom: 130rpx;
		left: calc(50% - 39rpx);
		width: 76rpx;
		height: 76rpx;
	}
	.btn {
		width: 690rpx;
		height: 80rpx;
		border-radius: 4rpx;
		background: #00B34D;
	}
	.input_box {
		border-bottom: 1rpx solid #e0e0e0;
		margin-top: 69rpx;
		padding-bottom: 22rpx;
		padding-left: 13rpx;
		image {
			width: 40rpx;
			height: 40rpx;
			margin-right: 48rpx;
			z-index: 999;
		}
	}
	.logo {
		width: 180rpx;
		height: 180rpx;
		border-radius: 12rpx;
		margin: 120rpx auto;
		display: block;
	}
}
</style>
